
package cn.yunyichina.scheduler.jobs.entity.register;

import cn.yunyichina.scheduler.jobs.common.hash.SimpleHashTableNameGenerator;
import cn.yunyichina.scheduler.jobs.constant.BizConstant;
import cn.yunyichina.scheduler.jobs.constant.OrderConstant;
import cn.yunyichina.scheduler.jobs.entity.message.MsgPushEntity;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

public abstract class Record extends MsgPushEntity implements Serializable {

	
	protected String hospitalId;

	
	protected String hospitalCode;

	
	protected String hospitalName;

	
	protected String branchHospitalId;

	
	protected String branchHospitalCode;

	
	protected String branchHospitalName;

	
	protected String openId;

	
	protected String userId;

	
	protected String patientName;

	
	protected String encryptedPatientName;

	
	protected String patientMobile;

	
	protected Integer patientSex;

	
	protected String patientSexLable;

	
	protected Integer idType;

	
	protected String idNo;

	
	protected Integer cardType;

	
	protected String cardNo;

	
	protected String encryptedCardNo;

	
	protected Long updateTime;

	
	protected Integer tradeMode;

	
	protected Integer payTotalFee;

	
	protected Long payTime;

	
	protected Integer refundTotalFee;

	
	protected Long refundTime;

	
	protected String orderNo;

	
	protected Integer orderNoHashVal;

	
	protected String refundOrderNo;


	protected String hisOrdNo;

	
	protected String refundHisOrdNo;

	
	protected String agtOrdNum;

	
	protected String agtRefundOrdNum;

	
	protected String feeDesc;

	
	protected Integer isHadCallBack;

	
	protected String recordTitle;

	
	protected String appId;

	
	protected String appCode;

	
	protected String appUrl;

	
	protected String failureMsg;

	
	protected Integer payStatus;

	
	protected String hashTableName;

	
	protected String receiptNum;

	
	protected String payTimeLabel;

	
	protected String payDate;

	
	protected String refundTimeLabel;

	
	protected String isInsurance;

	protected String medicalCardNo;

	
	protected String medicareCardNo;


	

	public Record(String orderNo) {
		super();
		this.orderNo = orderNo;
	}

	public Record() {
		super();
		// TODO Auto-generated constructor stub
	}

	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	public String getHospitalCode() {
		return hospitalCode;
	}

	public void setHospitalCode(String hospitalCode) {
		this.hospitalCode = hospitalCode;
	}

	public String getHospitalName() {
		return hospitalName;
	}

	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}

	public String getBranchHospitalId() {
		return branchHospitalId;
	}

	public void setBranchHospitalId(String branchHospitalId) {
		this.branchHospitalId = branchHospitalId;
	}

	public String getBranchHospitalCode() {
		return branchHospitalCode;
	}

	public void setBranchHospitalCode(String branchHospitalCode) {
		this.branchHospitalCode = branchHospitalCode;
	}

	public String getPatientName() {
		return patientName;
	}

	public String getPatientMobile() {
		return patientMobile;
	}

	public Long getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Long updateTime) {
		this.updateTime = updateTime;
	}

	public void setPatientName(String patientName) {
		this.patientName = patientName == null ? null : patientName.trim();
	}

	public void setPatientMobile(String patientMobile) {
		this.patientMobile = patientMobile == null ? null : patientMobile.trim();
	}

	public String getFeeDesc() {
		return feeDesc;
	}

	public void setFeeDesc(String feeDesc) {
		this.feeDesc = feeDesc == null ? null : feeDesc.trim();
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public Integer getOrderNoHashVal() {
		return orderNoHashVal;
	}

	public void setOrderNoHashVal(Integer orderNoHashVal) {
		this.orderNoHashVal = orderNoHashVal;
	}

	public String getRefundOrderNo() {
		return refundOrderNo;
	}

	public void setRefundOrderNo(String refundOrderNo) {
		this.refundOrderNo = refundOrderNo;
	}

	public String getHisOrdNo() {
		return hisOrdNo;
	}

	public void setHisOrdNo(String hisOrdNo) {
		this.hisOrdNo = hisOrdNo;
	}

	public String getRefundHisOrdNo() {
		return refundHisOrdNo;
	}

	public void setRefundHisOrdNo(String refundHisOrdNo) {
		this.refundHisOrdNo = refundHisOrdNo;
	}

	public String getAppId() {
		return appId;
	}

	public void setAppId(String appId) {
		this.appId = appId;
	}

	public String getAppCode() {
		return appCode;
	}

	public void setAppCode(String appCode) {
		this.appCode = appCode;
	}

	public String getAppUrl() {
		return appUrl;
	}

	public void setAppUrl(String appUrl) {
		this.appUrl = appUrl;
	}

	public String getAgtOrdNum() {
		return agtOrdNum;
	}

	public void setAgtOrdNum(String agtOrdNum) {
		this.agtOrdNum = agtOrdNum;
	}

	public String getAgtRefundOrdNum() {
		return agtRefundOrdNum;
	}

	public void setAgtRefundOrdNum(String agtRefundOrdNum) {
		this.agtRefundOrdNum = agtRefundOrdNum;
	}

	public Integer getIsHadCallBack() {
		return isHadCallBack;
	}

	public void setIsHadCallBack(Integer isHadCallBack) {
		this.isHadCallBack = isHadCallBack;
	}

	public String getRecordTitle() {
		return recordTitle;
	}

	public void setRecordTitle(String recordTitle) {
		this.recordTitle = recordTitle;
	}

	public String getFailureMsg() {
		return failureMsg;
	}

	public void setFailureMsg(String failureMsg) {
		this.failureMsg = failureMsg;
	}

	public Integer getPatientSex() {
		return patientSex;
	}

	public void setPatientSex(Integer patientSex) {
		this.patientSex = patientSex;
	}

	public Integer getIdType() {
		return idType;
	}

	public void setIdType(Integer idType) {
		this.idType = idType;
	}

	public String getIdNo() {
		return idNo;
	}

	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}

	public String getPatientSexLable() {
		if (patientSex != null) {
			if (patientSex.intValue() == BizConstant.SEX_MAN) {
				patientSexLable = "男";
			} else {
				patientSexLable = "女";
			}
		} else {
			patientSexLable = "男";
		}

		return patientSexLable;
	}

	public void setPatientSexLable(String patientSexLable) {
		this.patientSexLable = patientSexLable;
	}

	public Integer getCardType() {
		return cardType;
	}

	public void setCardType(Integer cardType) {
		this.cardType = cardType;
	}

	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	public Integer getPayStatus() {
		return payStatus;
	}

	public void setPayStatus(Integer payStatus) {
		this.payStatus = payStatus;
	}

	public Long getPayTime() {
		return payTime;
	}

	public void setPayTime(Long payTime) {
		this.payTime = payTime;
	}

	public Long getRefundTime() {
		return refundTime;
	}

	public void setRefundTime(Long refundTime) {
		this.refundTime = refundTime;
	}

	public String getEncryptedPatientName() {
		if (StringUtils.isNotEmpty(patientName)) {
			encryptedPatientName = patientName.replaceFirst("[\u4E00-\u9FA5]", BizConstant.VIEW_SENSITIVE_CHAR);
		}
		return encryptedPatientName;
	}

	public void setEncryptedPatientName(String encryptedPatientName) {
		this.encryptedPatientName = encryptedPatientName;
	}

	public String getHashTableName() {
		if (StringUtils.isBlank(hashTableName)) {
			hashTableName = SimpleHashTableNameGenerator.getRegRecordHashTable(userId);
		}
		return hashTableName;
	}

	public String getPayDate() {
		if (payTime != null) {
			payDate = BizConstant.YYYYMMDD.format(new Date(payTime));
		}
		return payDate;
	}

	public void setPayDate(String payDate) {
		this.payDate = payDate;
	}

	@SuppressWarnings("unused")
	private void setHashTableName(String hashTableName) {
		this.hashTableName = hashTableName;
	}

	public String getEncryptedCardNo() {
		if (StringUtils.isNotEmpty(cardNo) && cardNo.length() > 2) {
			int count = cardNo.length() / 3;
			if (count == 0) {
				count = count - 1;
			} else if (count > 3) {
				count = 3;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(cardNo.substring(0, count));
			sb.append(cardNo.substring(count, cardNo.length() - count).replaceAll("[0-9]", BizConstant.VIEW_SENSITIVE_CHAR));
			sb.append(cardNo.substring(cardNo.length() - count, cardNo.length()));
			encryptedCardNo = sb.toString();
		} else {
			encryptedCardNo = cardNo;
		}
		return encryptedCardNo;
	}

	public void setEncryptedCardNo(String encryptedCardNo) {
		this.encryptedCardNo = encryptedCardNo;
	}

	public abstract Integer getPayTotalFee();


	public void setPayTotalFee(Integer payTotalFee) {
		this.payTotalFee = payTotalFee;
	}


	public abstract Integer getRefundTotalFee();

	public void setRefundTotalFee(Integer refundTotalFee) {
		this.refundTotalFee = refundTotalFee;
	}

	public String getPayTimeLabel() {
		if (payTime != null) {
			payTimeLabel = BizConstant.YYYYMMDDHHMMSS.format(new Date(payTime));
		}
		return payTimeLabel;
	}

	public void setPayTimeLabel(String payTimeLabel) {
		this.payTimeLabel = payTimeLabel;
	}

	public String getRefundTimeLabel() {
		if (refundTime != null) {
			refundTimeLabel = BizConstant.YYYYMMDDHHMMSS.format(new Date(refundTime));
		}
		return refundTimeLabel;
	}

	public void setRefundTimeLabel(String refundTimeLabel) {
		this.refundTimeLabel = refundTimeLabel;
	}

	public String getReceiptNum() {
		if (StringUtils.isBlank(receiptNum) || "null".equals(receiptNum)) {
			receiptNum = "";
		}

		return receiptNum;
	}

	public void setReceiptNum(String receiptNum) {
		this.receiptNum = receiptNum;
	}

	public String getBranchHospitalName() {
		return branchHospitalName;
	}

	public void setBranchHospitalName(String branchHospitalName) {
		this.branchHospitalName = branchHospitalName;
	}

	public Integer getTradeMode() {
		return tradeMode;
	}

	public void setTradeMode(Integer tradeMode) {
		this.tradeMode = tradeMode;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public int getOrderType() {
		int orderType = 0;
		if (BizConstant.MODE_TYPE_ALIPAY.equalsIgnoreCase(appCode)) {
			orderType = OrderConstant.ORDER_TYPE_ALIPAY;
		} else if (BizConstant.MODE_TYPE_WEIXIN.equalsIgnoreCase(appCode)) {
			orderType = OrderConstant.ORDER_TYPE_WEIXIN;
		} else if (BizConstant.MODE_TYPE_EASYHEALTH.equalsIgnoreCase(appCode)) {
			if(tradeMode==2){
				tradeMode=5;
			}
			orderType = tradeMode;
		}

		return orderType;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public String getIsInsurance() {
		return isInsurance;
	}

	public void setIsInsurance(String isInsurance) {
		this.isInsurance = isInsurance;
	}

	public String getMedicalCardNo() {
		return medicalCardNo;
	}

	public void setMedicalCardNo(String medicalCardNo) {
		this.medicalCardNo = medicalCardNo;
	}

	public String getMedicareCardNo() {
		return medicareCardNo;
	}

	public void setMedicareCardNo(String medicareCardNo) {
		this.medicareCardNo = medicareCardNo;
	}

}
